// app.js

App({

  onLaunch() {

  },

  tick: function () {
    let s = parseInt(this.globalData.second);
    let m = parseInt(this.globalData.minute);
    let h = parseInt(this.globalData.hour);
    s++;
    if (s === 60) {
      s = 0;
      m++;
      if (m === 60) {
        m = 0;
        h++;
      }
    }
    s = '' + s;
    if (s.length < 2) {
      s = '0' + s;
    }
    m = '' + m;
    if (m.length < 2) {
      m = '0' + m;
    }
    h = '' + h;
    if (h.length < 2) {
      h = '0' + h;
    }
    this.globalData.second = s;
    this.globalData.minute = m;
    this.globalData.hour = h;
  },

  timerStart: function () {
    let timerId = setInterval(this.tick, 1000);
    this.globalData.timerId = timerId;
    this.globalData.timerOn = true;
  },

  timerStop: function () {
    clearInterval(this.globalData.timerId);
    this.globalData.second = '00';
    this.globalData.minute = '00';
    this.globalData.hour = '00';
    this.globalData.timerOn = false;
  },

  globalData: {
    second: '00',
    minute: '00',
    hour: '00',
    timerId: 0,
    timerOn: false,
    SDKAppID: 1400650939,
    prefix: 'http://106.14.247.163:8080'
  }


})